package com.zc.controller;

import com.zc.pojo.Orders;
import com.zc.service.center.MyOrdersService;
import com.zc.utils.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.io.File;

/**
 * @author 曾川
 * @version 1.0.0
 * @ClassName HelloController.java
 * @Description TODO
 * @createTime 2021年06月29日 10:05:00
 */
@Controller
public class BaseController {

    public static final String FOODIE_SHOPCART = "shopcart";

    public static final Integer COMMON_PAGE_SIZE = 10;
    public static final Integer PAGE_SIZE = 20;

    // 支付中心的调用地址
    String paymentUrl = "";		// produce

    // 微信支付成功 -> 支付中心 -> 天天吃货平台
    //                       |-> 回调通知的url
//    String payReturnUrl = "http://localhost:8088/orders/notifyMerchantOrderPaid";
    //内网穿透地址，需要不定时更换
    String payReturnUrl = "http://vmx5b7.natappfree.cc/orders/notifyMerchantOrderPaid";

    //用户上传头像的地址
    public static final String IMAGE_USER_FACE_LOCATION= "D:" + File.separator +  "JavaWorkspace"
                                                        + File.separator + "workspaces"
                                                        + File.separator +  "images"
                                                        + File.separator +  "foodie"
                                                        + File.separator +  "faces";


    @Autowired
    public MyOrdersService myOrdersService;

    /**
     * 用于验证用户和订单是否有关联关系，避免非法用户调用
     * @return
     */
    public JSONResult checkUserOrder(String userId, String orderId) {
        Orders order = myOrdersService.queryMyOrder(userId, orderId);
        if (order == null) {
            return JSONResult.errorMsg("订单不存在！");
        }
        return JSONResult.ok(order);
    }

}
